package com.example.pclimb.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.pclimb.model.GuideImage;
import com.example.pclimb.repository.GuideImageRepository;

import java.util.List;

/**
 * 向导证书图片ViewModel类
 */
public class GuideImageViewModel extends AndroidViewModel {

    private GuideImageRepository repository;

    public GuideImageViewModel(@NonNull Application application) {
        super(application);
        repository = new GuideImageRepository(application);
    }

    /**
     * 添加证书图片
     */
    public void addImage(GuideImage guideImage) {
        repository.insert(guideImage);
    }

    /**
     * 删除证书图片
     */
    public void deleteImage(GuideImage guideImage) {
        repository.delete(guideImage);
    }

    /**
     * 获取图片通过ID
     */
    public LiveData<GuideImage> getImageById(int id) {
        return repository.getImageById(id);
    }

    /**
     * 获取用户的所有证书图片
     */
    public LiveData<List<GuideImage>> getUserImages(int userId) {
        return repository.getUserImages(userId);
    }

    /**
     * 获取用户的证书图片数量
     */
    public int getUserImageCount(int userId) {
        return repository.getUserImageCount(userId);
    }

    /**
     * 删除用户的所有证书图片
     */
    public void deleteUserImages(int userId) {
        repository.deleteUserImages(userId);
    }
} 